﻿using System;
using System.Configuration;
using mojoPortal.Net;
using mojoPortal.Web;
using Resources;
using mojoPortal.Web.Framework;
using System.Collections;
using mojoPortal.Business;
using ud_gSDMS.Code_Service;
using mojoPortal.Business.WebHelpers;
using System.IO;
using Brettle.Web.NeatUpload;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace ud_gSDMS.Member
{
    public partial class UpdateCBInfo_DHQG : mojoBasePage
    {
        private int pageId = -1;
        private int moduleId = -1;
        private string id;
        private SiteUser _siteUser;
        protected String cacheDependencyKey;
        DBQLNS _respository=new DBQLNS();
        
        void Page_Load(object sender, EventArgs e)
        {
            _siteUser = SiteUtils.GetCurrentSiteUser();
            if (_siteUser == null)
            {
                WebUtils.SetupRedirect(this, SiteRoot + "/AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                PopulateLabels();
                PopulateControls();
            }
        }
        private void PopulateLabels()
        {
            CBQGTest child1 = new CBQGTest("1", "0298", "Nguyễn Lê Nguyên Ngữ", "", "", "- -", "", "", "", "", "BGH", "15.111", "", "", "- -", "ĐH", "", "GV", "", "CH", "", "", "");
            CBQGTest child2 = new CBQGTest("2", "0303", "Trần Thu Hằng", "x", "", "- -", "", "", "", "", "BGH", "01.003", "", "", "- -", "ĐH", "", "CV", "", "CH", "", "", "");
            CBQGTest child3 = new CBQGTest("3", "0305", "Lưu Bích Phượng", "x", "", "- -", "", "", "", "", "BGH", "01.003", "", "", "- -", "ĐH", "", "CV", "", "CH", "", "", "");
            List<CBQGTest> lst = new List<CBQGTest>();
            lst.Add(child1);
            lst.Add(child2);
            lst.Add(child3);
            Session["Cbqg"] = lst;
        }
        private void BindData()
        {
            gvChildInfo.DataSource = Session["Cbqg"];
            gvChildInfo.DataBind();
        }

        private void PopulateControls()
        {
            BindData();
        }
        #region OnInit

        protected override void OnPreInit(EventArgs e)
        {
            AllowSkinOverride = true;
            base.OnPreInit(e);
            Load += Page_Load;
        }

        protected override void OnInit(EventArgs e)
        {
            LoadParams();
            LoadPanels();
            base.OnInit(e);
            SuppressPageMenu();
        }

        private void LoadParams()
        {
            pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, moduleId);
            id = WebUtils.ParseStringFromQueryString("id", id);
            cacheDependencyKey = "Module-" + moduleId.ToInvariantString();
        }

        private void LoadPanels()
        {
            bool showLeftColumnAdmin = ConfigHelper.GetBoolProperty("ShowLeftColumnAdmin", false);
            bool showRightColumnAdmin = ConfigHelper.GetBoolProperty("ShowRightColumnAdmin", false);
            bool showTopColumnAdmin = ConfigHelper.GetBoolProperty("ShowTopColumnAdmin", false);
            bool showBottomColumnAdmin = ConfigHelper.GetBoolProperty("ShowBottomColumnAdmin", false);
            int showCenterColumnAdmin = ConfigHelper.GetIntProperty("ShowCenterColumnAdmin", 0);
            LoadSideContent(showLeftColumnAdmin, showRightColumnAdmin, showTopColumnAdmin, showBottomColumnAdmin, showCenterColumnAdmin);
        }
        #endregion

        protected void gvChildInfo_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvChildInfo.EditIndex = e.NewEditIndex;
            BindData();
        }

        protected void gvChildInfo_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvChildInfo.EditIndex = -1;
            BindData();
        }

        protected void gvChildInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            List<CBQGTest> l = (List<CBQGTest>)Session["Cbqg"];
            TextBox txt_maso = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt1");
            TextBox txt_hoten = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt2");
            TextBox txt_nu = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt3");
            TextBox txt_quequan = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt4");
            TextBox txt_ngaysinh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt5");
            TextBox txt_chucvu = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt6");
            TextBox txt_dv = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt7");
            TextBox txt_donvi = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt8");
            TextBox txt_kh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt9");
            TextBox txt_khoabm = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt10");
            TextBox txt_ngach = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt11");
            TextBox txt_bac = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt12");
            TextBox txt_hslg = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt13");
            TextBox txt_ngaytlgn = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt14");
            TextBox txt_trinhdo = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt15");
            TextBox txt_chuyennganh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt16");
            TextBox txt_chucdanh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt17");
            TextBox txt_danhhieu = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt18");
            TextBox txt_loaicb = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt19");
            TextBox txt_dangv = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt20");
            TextBox txt_coluong = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt21");
            TextBox txt_nghiviec = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt22");
            string tam = l[e.RowIndex].ID;
            CBQGTest newreward = new CBQGTest(tam, txt_maso.Text, txt_hoten.Text, txt_nu.Text, txt_quequan.Text, txt_ngaysinh.Text, txt_chucvu.Text, txt_dv.Text, txt_donvi.Text, txt_kh.Text, txt_khoabm.Text, txt_ngach.Text, txt_bac.Text,
                txt_hslg.Text, txt_ngaytlgn.Text, txt_trinhdo.Text, txt_chuyennganh.Text, txt_chucdanh.Text, txt_danhhieu.Text, txt_loaicb.Text, txt_dangv.Text, txt_coluong.Text, txt_nghiviec.Text);
            l[e.RowIndex] = newreward;
            gvChildInfo.EditIndex = -1;
            BindData();
        }

        protected void gvChildInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            List<CBQGTest> l = (List<CBQGTest>)Session["Cbqg"];
            l.RemoveAt(e.RowIndex);
            BindData();
        }
    }

    public class CBQGTest
    {
        public string ID { get; set; }
        public string MaSo { get; set; }
        public string HoTen {get ; set;}
        public string Nu { get; set; }
        public string Quequan { get; set; }
        public string NgaySinh { get; set; }
        public string ChucVu { get; set; }
        public string DV { get; set; }
        public string Donvi { get; set; }
        public string KH { get; set; }
        public string KhoaBM { get; set; }
        public string Ngach { get; set; }
        public string Bac { get; set; }
        public string HSLg { get; set; }
        public string NgayTLGN { get; set; }
        public string TrinhDo { get; set; }
        public string ChuyenNganh { get; set; }
        public string ChucDanh { get; set; }
        public string DanhHieu { get; set; }
        public string LoaiCB { get; set; }
        public string DangV { get; set; }
        public string CoLuong { get; set; }
        public string NghiViec { get; set; }
        public CBQGTest(string id, string maso, string hoten, string nu, string quequan, string ngaysinh, string chucVu, string dv, string donvi, string kh, string KhoaBM, string ngach, string bac, string hsLg, string NgayTLGN, string TrinhDo, string ChuyenNganh
            , string ChucDanh, string DanhHieu, string LoaiCB, string DangV, string coLuong, string NghiViec)
        {
            this.ID = id;
            this.MaSo = maso;
            this.HoTen = hoten;
            this.Nu = nu;
            this.Quequan = quequan;
            this.NgaySinh = ngaysinh;
            this.ChucVu = chucVu;
            this.DV = dv;
            this.Donvi = donvi;
            this.KH = kh;
            this.KhoaBM = KhoaBM;
            this.Ngach = ngach;
            this.Bac = bac;
            this.HSLg = hsLg;
            this.NgayTLGN = NgayTLGN;
            this.TrinhDo = TrinhDo;
            this.ChuyenNganh = ChuyenNganh;
            this.ChucDanh = ChucDanh;
            this.DanhHieu = DanhHieu;
            this.LoaiCB = LoaiCB;
            this.DangV = DangV;
            this.CoLuong = coLuong;
            this.NghiViec = NghiViec;
        }
    }

    
}